package AdapterPattern.exercise2_2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class FileProperties extends Properties implements FileIO {
    public FileProperties() {

    }

    @Override
    public void readFromFile(String filename) throws IOException {
        FileInputStream fis = new FileInputStream(filename);
        this.load(fis);
    }

    @Override
    public void writeToFile(String filename) throws IOException {
        FileOutputStream fos = new FileOutputStream(filename);
        this.store(fos, "Write By LiMingChen");
    }

    @Override
    public void setValue(String key, String value) {
        setProperty(key,value);
    }

    @Override
    public String getValue(String key) {
        return getProperty(key,"");
    }
}
